package cn.wsalix.spring.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author jskyme
 * http://www.xuebuyuan.com/2225265.html
 * http://www.cnblogs.com/hongwz/p/5642497.html Spring任务调度之Spring-Task
 */
@Component("changeStateTask")
public class ChangeStateTask {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	/*
	 * @Autowired private ContractServiceImpl contractServiceImpl;
	 *//**
	 * 定时更改状态 0 0 * * * ? 表示每次秒和分为0时触发一次（每小时一次）
	 * "@Scheduled"时spring提供的定时任务标签 需要在applicationContext.xml中添加
	 * xmlns:task="http://www.springframework.org/schema/task"
	 * xsi:schemaLocation=
	 * "http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd "
	 * <task:annotation-driven scheduler="qbScheduler" mode="proxy"/>
	 * <task:scheduler id="qbScheduler" pool-size="10"/ ChangeStateTask.doJob()<BR>
	 */
	@Scheduled(cron = "0 0 * * * ?")
	public void doJob() {
		logger.info("..............doJob.............");
		// this.contractServiceImpl.executeStateChange();
	}

	/**
	 * 固定每分钟执行一次 ChangeStateTask.doJob1()<BR>
	 */
	@Scheduled(fixedRate = 60 * 60 * 1000)
	public void doJob1() {
		logger.info("..............doJob1.............");
	}

	/**
	 * 上次任务结束后一分钟后再次执行 ChangeStateTask.doJob2()<BR>
	 */
	@Scheduled(fixedDelay = 30 * 60 * 1000)
	public void doJob2() {
		logger.info(".............doJob2..............");
	}
}